﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using StyleMVVM.Data.Activation;

namespace StyleMVVM.Data.Activation
{
	public static class IActivationServiceExtensions
	{
		/// <summary>
		/// Creates a new instance of T
		/// </summary>
		/// <typeparam name="T"></typeparam>
		/// <param name="activationService"></param>
		/// <param name="parameters"></param>
		/// <returns></returns>
		public static T Create<T>(this IActivationService activationService, params object[] parameters)
		{
			return (T)activationService.CreateByType(
				Bootstrapper.Instance.Container.CreateInjectionContext(), typeof(T), parameters);
		}

		/// <summary>
		/// Creates a deep clone of the specified object.
		/// </summary>
		/// <typeparam name="T">Type of object to clone</typeparam>
		/// <param name="activationService"> </param>
		/// <param name="value">object to clone</param>
		/// <returns></returns>
		public static T DeepClone<T>(this IActivationService activationService, T value)
		{
			return (T)activationService.DeepClone(value);
		}

		/// <summary>
		/// Clone one object into another.
		/// </summary>
		/// <typeparam name="T"></typeparam>
		/// <param name="activationService"> </param>
		/// <param name="value"></param>
		/// <param name="tInstance"></param>
		/// <returns></returns>
		public static T DeepCloneIntoInstance<T>(this IActivationService activationService, T value, T tInstance)
		{
			return (T)activationService.DeepCloneIntoInstance(value, tInstance);
		}
	}
}